package com.framework.Module.system.dept;



import com.framerock.baselib.Rock;
import com.framework.Table.Table;


public class Tabledept extends Table {

    protected void initTable() {
        this.tablename   = "dept";
        this.tablenamesm = "单位部门";

        this.flowsetMap  = Rock.getMap(new String[]{
                "type", "系统",
                "sort", "908",
                "isxt", "2",
        });

        this.addfields("name", "varchar(100)", "", "名称", new String[]{
                "isbt","1",
                "isss", "1",
                "isalign","1"
        });
        this.addfields("headman", "varchar(50)", "", "负责人@headid@可多选负责人", new String[]{
                "fieldstype","changeusercheck",
        });
        this.addfields("headid", "varchar(50)", "", "负责人ID", new String[]{
                "islb","0",
                "notelement","1"
        });
        this.addfields("pid", "int(11)", "0", "上级ID");
        this.addfields("sort", "int(11)", "0", "排序号", new String[]{
                "iseditlx","2"
        });
        this.addfields("cid", "int(11)", "0", "单位ID", new String[]{
                "islu","0",
                "attr","readonly"
        });

        this.addfields("id", "int(11)", "0", "ID");
        this.addfields("cid", "KEY", "`cid`", "单位ID");
        this.addfields("id_cid", "UNIQUE KEY", "`id`,`cid`", "唯一索引");
    }

    //创建创建第一个单位下部门
    protected void firstInsert() {
        int count = this.nDb.getCount(this.tablenameal, "`id`=1 and `cid`=1");
        if(count==0) {
            this.nDb.insertbo(this.tablenameal, Rock.getMap(new String[]{
                    "id", "1",
                    "cid", "1",
                    "name", "信呼Java开发团队",
            }));
            this.nDb.insertbo(this.tablenameal, Rock.getMap(new String[]{
                    "pid", "1",
                    "cid", "1",
                    "name", "技术部",
            }));
        }
    }
}
